package com.koocloud.electroplatemanage.controller;

import com.koocloud.electroplatemanage.common.pojo.ResponseTemplate;
import com.koocloud.electroplatemanage.pojo.IncomePartJudgeFieldVo;
import com.koocloud.electroplatemanage.service.IncomePartJudgeFieldService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: electroplatemanage
 * @description: 来料接收与判定字段控制层(扩列访问接口)
 * @author: zww
 * @create: 2020-10-10 10:56
 */
@RestController
@RequestMapping("/incomepartjudgefield")
public class IncomePartJudgeFieldController {
    static Logger log = Logger.getLogger("incomepartjudgefield");
    @Autowired
    IncomePartJudgeFieldService incomePartJudgeFieldService;
    /**
     * @Description:查询来料接收与判定表字段表启用字段的相关信息(根据orderid排序)
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/10/10
     */
    @RequestMapping(value = "/selectEnableFieldInfo", method = RequestMethod.POST, name = "启用字段信息查询")
    public ResponseTemplate selectEnableFieldInfo(@RequestParam(value = "page") String page,@RequestParam(value = "limit") String limit,@RequestParam(value = "idOrName")String idOrName) {
        //分页参数为空则赋值0
        if (!StringUtils.isNotEmpty(page)) {
            page = "0";
        }
        if (!StringUtils.isNotEmpty(limit)) {
            limit = "0";
        }
        //查询来料接收与判定表字段表启用字段的相关信息(根据orderid排序)
        return incomePartJudgeFieldService.selectEnableFieldInfo(page,limit,idOrName);
    }
    /**
     * @Description:查询来料接收与判定表字段表启用字段信息查询的相关信息并驼峰(根据orderid排序)
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/10/14
     */
    @RequestMapping(value = "/selectEnableFieldInfoForVo", method = RequestMethod.POST, name = "启用字段信息查询并驼峰")
    public ResponseTemplate selectEnableFieldInfoForVo() {
        //查询来料接收与判定表字段表启用字段的相关信息(根据orderid排序)
        return incomePartJudgeFieldService.selectEnableFieldInfoForVo();
    }

    /**
     * @Description:查询来料接收与判定表字段表非权限启用字段信息查询的相关信息并驼峰(根据orderid排序)
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/11/2
     */
    @RequestMapping(value = "/selectNotAuthEnableFieldInfo", method = RequestMethod.POST, name = "非权限启用字段信息查询")
    public ResponseTemplate selectNotAuthEnableFieldInfo() {
        //查询来料接收与判定表字段表非权限启用字段的相关信息(根据orderid排序)
        return incomePartJudgeFieldService.selectNotAuthEnableFieldInfo();
    }
    /**
     * @Description:查询来料接收与判定表字段表启用字段数
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/10/10
     */
    @RequestMapping(value = "/selectCountEnableField", method = RequestMethod.POST, name = "启用字段数查询")
    public ResponseTemplate selectCountEnableField() {
        //查询来料接收与判定表字段表启用字段数
        return incomePartJudgeFieldService.selectCountEnableField();
    }


    /**
     * @Description:查询数据库最大orderId
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/10/16
     */
    @RequestMapping(value = "/selectFieldMaxOrderId", method = RequestMethod.POST, name = "查询数据库最大orderId")
    public ResponseTemplate selectFieldMaxOrderId() {
        //最小未启用字段序列号查询
        return incomePartJudgeFieldService.selectFieldMaxOrderId();
    }

    /**
     * @Description:查询默认科目号
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/11/09
     */
    @RequestMapping(value = "/selectProjectNo", method = RequestMethod.POST, name = "查询默认科目号")
    public ResponseTemplate selectProjectNo() {
        //最小未启用字段序列号查询
        return incomePartJudgeFieldService.selectProjectNo();
    }

    /**
     * @Description:新增扩列字段
     * @Param:
     * @return: com.koocloud.electroplatemanage.common.ResponseTemplate
     * @Author: zww
     * @date: 2020/10/16
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST, name = "扩列新增")
    public ResponseTemplate insert(@RequestBody IncomePartJudgeFieldVo incomePartJudgeFieldVo) {
        //新增扩列数据
        return incomePartJudgeFieldService.insert(incomePartJudgeFieldVo);
    }
   /**
     *@Description:逻辑删除一条记录
     *@Param: [fieldCode]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/10/10
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST, name = "逻辑删除一条记录")
    public ResponseTemplate delete(@RequestParam(name="fieldCode") String fieldCode, @RequestParam(name="enableFlag") String enableFlag) {
        //逻辑删除一条记录
        return incomePartJudgeFieldService.delete(fieldCode,enableFlag);
    }
    /**
     *@Description:修改一条记录
     *@Param: [IncomePartJudgeFieldVo]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/10/10
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST, name = "修改一条记录")
    public ResponseTemplate update(@RequestBody IncomePartJudgeFieldVo incomePartJudgeFieldVo) {
        //修改一条记录
        return incomePartJudgeFieldService.update(incomePartJudgeFieldVo);
    }

    /**
     *@Description:校验能否进行扩列
     *@Param: []
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/10/16
     */
    @RequestMapping(value = "/checkExpansion", method = RequestMethod.POST, name = "能否进行扩列")
    public ResponseTemplate checkExpansion() {
        //校验能否扩列
        return incomePartJudgeFieldService.checkExpansion();
    }
    /**
     *@Description:校验orderId 起校验功能(必须输入大于0小于等于orderId)
     *@Param: [orderId]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/10/16
     */
    @RequestMapping(value = "/checkOrderId", method = RequestMethod.POST, name = "校验orderId")
    public ResponseTemplate checkOrderId(int orderId) {
        //校验orderId
        return incomePartJudgeFieldService.checkOrderId(orderId);
    }
    /**
     *@Description:校验formula 起校验功能(仅支持九位+-*=/其中=表示字符串拼接)
     *@Param: [formula]
     *@return: com.koocloud.electroplatemanage.common.ResponseTemplate
     *@Author: zww
     *@date: 2020/10/27
     */
    @RequestMapping(value = "/checkFormula", method = RequestMethod.POST, name = "校验formula")
    public ResponseTemplate checkFormula(String formula) {
        //校验orderId
        return incomePartJudgeFieldService.checkFormula(formula);
    }
}